<script setup>
import { cityGetService } from '@/api/city'
import { ref } from 'vue'

defineProps({
  modelValue: {
    type: Array
  },
  width: {
    type: String
  }
})
const emit = defineEmits(['update:modelValue'])
const elementList = ref([])
const getTagList = async () => {
  const res = await cityGetService()
  elementList.value = res.data.data
  console.log(res.data)
}
getTagList()

// onMounted(getTagList)
</script>

<template>
  <!-- label 展示给用户看的，value 收集起来提交给后台的 -->
  <el-select
    multiple
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
    style="width: 900px; max-width: 1000px; height: 40px"
    :style="{ width }"
  >
    <el-option
      v-for="element in elementList"
      :key="element.id"
      :label="element.elementName"
      :value="element.id"
    ></el-option>
  </el-select>
</template>

<style lang="scss" scoped></style>
